<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$Think.config.site.title} - 租还订单</title>

    <meta name="keywords" content="{$Think.config.site.keywords}">
    <meta name="description" content="{$Think.config.site.description}">
    <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/animate.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.css?v=4.1.0" rel="stylesheet">
    <style>
        #listtable .fa{    cursor: pointer;color: #1ab394;margin-right: 1em;}
    </style>
</head>

<body >
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <style type="text/css">.col-sm-12 label{ font-weight:300; }</style>
            <div class="ibox float-e-margins">
                <div class="">
                    <h5>{:lang('租还订单')}</h5>
                </div>
                <div class="row ibox-title">
                    <form action="" method="post" name="leaseorder">
                        <!-- <label>每页 </label>
                        <label>
                            <select name="pages" class="input-sm form-control">
                                <option value="10">10</option>
                                <option value="15">15</option>
                                <option value="25">25</option>
                                <option value="35">35</option>
                                <option value="50">50</option>
                                <option value="100">100</option>
                            </select>
                        </label>
                        <label > 条记录</label> -->　
                        　　 <label >{:lang('订单ID')}：</label>
                        <label ><input type="text" class="input-sm form-control" name="order_no" aria-controls="" placeholder="{:lang('输入')}{:lang('订单ID')}" value="{$order_no ?? ''}"></label>　　 　
                        <label >{:lang('用户名')}：</label>
                        <label><input type="text" class="input-sm form-control" name="name" aria-controls="" placeholder="{:lang('输入')}{:lang('用户名')}" value="{$name ?? ''}"></label>　　 　　
                        <label>{:lang('商户名称')}：</label>
                        <label ><input type="text" class="input-sm form-control" name="sname" aria-controls="" placeholder="{:lang('输入')}{:lang('商户名称')}" value="{$sname ?? ''}"></label>　　
                        <label>{:lang('订单状态')}：</label>
                        <label>
                            <select class="input-sm form-control" name="status">
                                <option value="">{:lang('选择订单状态')}</option>
                                <option value="1">{:lang('租借中')}</option>
                                <option value="2">{:lang('已完成')}</option>
                                <option value="3">{:lang('订单超时')}</option>
                                <option value="4">{:lang('异常')}</option>
                            </select>
                        </label>
                        <label><button type="submit" class="btn btn-sm btn-primary"> {:lang('提交')}</button> </label>
                    </form>
                </div>
                <div class="ibox-content">

                    <table class="table table-hover" id="listtable">
                        <thead>
                        <tr>
                            <th>{:lang('用户头像')}</th>
                            <th>{:lang('用户名称')}</th>
                            <th>{:lang('商户名称')}</th>
                            <th>{:lang('订单ID')}</th>
                            <th>{:lang('订单名称')}</th>
                            <th>{:lang('开始时间')}</th>
                            <th>{:lang('结束时间')}</th>
                            <th>{:lang('计费单位')}</th>
                            <th>{:lang('金额')}</th>
                            <th>{:lang('订单状态')}</th>
                            <th>{:lang('机柜ID')}</th>
                            <th>{:lang('充电宝ID')}</th>
                            <th>{:lang('操作')}</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="list" id="v"}
                        <tr data-id="{$v.id}">
                            <td> <img src="{$v.picture}" alt=""width="30" height="30"></td>
                            <td>{$v.name}</td>
                            <td>{$v.sname}</td>
                            <td>{$v.order_no}</td>
                            <td>{$v.lname}</td>
                            <td>{$v.starttime|date="Y-m-d H:i:s",###}</td>
                            <td>{if condition="$v['endtime'] neq ''"}{$v.endtime|date="Y-m-d H:i:s",###} {/if}</td>
                            <td>{$v.billingunit}</td>
                            <td>{$v.amount}</td>
                            <td>
                                {switch name="v.status"}
                                {case value="1"}{:lang('租借中')}{/case}
                                {case value="2"}{:lang('已完成')}{/case}
                                {case value="3"}{:lang('订单超时')}{/case}
                                {case value="4"}{:lang('异常')}{/case}
                                {/switch}
                            </td>
                            <td>{$v.cabinetid}</td>
                            <td>{$v.deviceid}</td>
                            <td> {if condition="($v['status'] eq 1) or ($v['status'] eq 4)"} <i class="fa fa-exclamation-triangle enorder"> {:lang('结束订单')}</i> {/if}</td>

                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>

                <div class="row">
                    <div class="col-sm-6">
                        <div class="dataTables_info" id="DataTables_Table_0_info" role="alert" aria-live="polite" aria-relevant="all"></div>
                    </div>
                    <div class="col-sm-6">
                        <div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
                            {$list->render()}
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
<script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
<script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.5"></script>
<script src="{$Think.config.site.resource_url}js/plugins/peity/jquery.peity.min.js"></script>
<script src="{$Think.config.site.resource_url}js/plugins/iCheck/icheck.min.js"></script>
<script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>
<style type="text/css">.layui-layer-btn{ text-align: center; }</style>
<script>
    var layer_font;
    var $editTr;
    $(document).ready(function() {
        //修改按钮
        $("#listtable").on("click",".fa-edit",function(){
            $editTr = $(this).closest("tr");
            var id = $editTr.data("id");
            layer_font = layer.open({
                type: 2,
                title: "{:lang('修改租还记录信息')}",
                shadeClose: true,
                shade: 0.8,
                area: ['80%', '90%'],
                content: '<?php echo \think\Request::instance()->root(); ?>/<?php echo \think\Request::instance()->module(); ?>/Orders/leaseorderedit?id='+id //iframe的url
            });
        });
        $("#listtable").on("click",".enorder",function(){
            $editTr = $(this).closest("tr");
            var id = $editTr.data("id");
            layer.confirm("{:lang('确定要结束该订单')}", {
                    btn: ["{:lang('不扣费')}","{:lang('扣费')}"], //按钮
                    shade: false //不显示遮罩
                }, function(){
                    //不扣费结束订单
                    $.ajax({
                        type : 'POST',//delete
                        url : '<?php echo \think\Request::instance()->root(); ?>/<?php echo \think\Request::instance()->module(); ?>/Orders/endorder',
                        dataType : 'json',
                        data : {id:id},
                        async:false,
                        success : function(result) {
                            //layer.close(layer1);
                            if(0 === result.code) {
                                window.location.reload();
                            }  else  {
                                //删除失败
                                layer.msg(result.msg, {icon: 5});
                            }
                        },
                        error : function(){
                            res = false;
                            layer.msg("{:lang('服务器错误！请稍后重试')}", {icon: 2});
                        }
                    })
                },
                function(){
                    //扣费结束订单
                    layer_font = layer.open({
                        type: 2,
                        title: "{:lang('结束租借订单操作')}",
                        shadeClose: true,
                        shade: 0.8,
                        area: ['40%', '80%'],
                        content: '<?php echo \think\Request::instance()->root(); ?>/<?php echo \think\Request::instance()->module(); ?>/Orders/endorder?id='+id //iframe的url
                    });

                });
        });

        //退款
        $("#listtable").on("click",".refund",function(){
            $editTr = $(this).closest("tr");
            var id = $editTr.data("id");
            layer.confirm("{:lang('确定要退款？')}", {
                    btn: ["{:lang('退款')}","{:lang('不退款')}"], //按钮
                    shade: false //不显示遮罩
                }, function(){
                    //确定删除
                    layer_font = layer.open({
                        type: 2,
                        title: "{:lang('租借订单退款')}",
                        shadeClose: true,
                        shade: 0.8,
                        area: ['40%', '70%'],
                        content: '<?php echo \think\Request::instance()->root(); ?>/<?php echo \think\Request::instance()->module(); ?>/Orders/refunds?id='+id //iframe的url
                    });
                },
                function(){

                });
        });
    });
</script>
<!--统计代码，可删除-->

</body>

</html>
